var util = require('../../../utils/util.js');
var api = require('../../../config/api.js');
var timer = require('../../../utils/wxTimer.js');
var remaintimer = require('../../../utils/remainTime.js');
const app = getApp()

// TODO 拼团订单不能退款
Page({
    data: {
        orderId: 0,
        type:0,
        orderInfo:''
    },
    onLoad: function (options) {
        this.setData({
            orderId:options.orderID,
            type:options.type
        });
    },
    onShow: function () {
        wx.showLoading({
            title: '加载中...',
        });
        this.getOrderDetail();
    },
    onUnload: function () {
        // let oCancel = this.data.handleOption.cancel;
        // if (oCancel == true) {
        //     let orderTimerID = this.data.wxTimerList.orderTimer.wxIntId;
        //     clearInterval(orderTimerID);
        // }
    },
    onHide: function () {
        // let oCancel = this.data.handleOption.cancel;
        // if (oCancel == true) {
        //     let orderTimerID = this.data.wxTimerList.orderTimer.wxIntId;
        //     clearInterval(orderTimerID);
        // }
    },
    // 获取订单详情
    getOrderDetail: function () {
        let that = this;
        util.requestApi(api.getOrderInfo, {
            orderID: that.data.orderId,
            type:that.data.type
        }).then(function (res) {
            if (res.code === 200) {
                that.setData({
                    orderInfo:res.content
                });
            }else{
                wx.showToast({
                  title: '获取详情失败',
                })
            }
        });
        wx.hideLoading();
    },
    // 预览定制图片
    preImg(e){
        var that = this;
        var src = e.currentTarget.dataset.src; //获取data-src
        var imgList = [src]; //获取data-list
        //图片预览
        wx.previewImage({
          current: src, // 当前显示图片的http链接
          urls: imgList // 需要预览的图片http链接列表
        })
    },
    goBack(){
        wx.navigateBack({
          delta: 1,
        })
    }
})